package com.shuyu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shuyu.domain.ActivityCollectCardTmp;
import com.shuyu.domain.ActivityProductTmp;
import com.shuyu.domain.ActivityTmp;
import com.shuyu.mapper.ActivityProductTmpMapper;
import com.shuyu.service.ActivityCollectCardTmpService;
import com.shuyu.service.ActivityProductTmpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ActivityProductTmpServiceImpl extends ServiceImpl<ActivityProductTmpMapper, ActivityProductTmp> implements ActivityProductTmpService {
    @Resource
    private ActivityCollectCardTmpService activityCollectCardTmpService;
    @Override
    public List<ActivityProductTmp> getProductListByActivityId(ActivityTmp activityTmp) {
        List<ActivityProductTmp> list = this.baseMapper.getProductListByActivityId(activityTmp.getId());
        if(activityTmp.getType()==1){//1：集卡消卡
            queryCollectCard(list);
        }
        return list;
    }
    private void queryCollectCard(List<ActivityProductTmp> list){
        for (ActivityProductTmp activityProduct : list) {
            List<ActivityCollectCardTmp> activityCollectCardList = activityCollectCardTmpService.getCollectCard(activityProduct.getId());
            activityProduct.setActivityCollectCardList(activityCollectCardList);
        }
    }
}
